package com.yeung.springcloud;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableEurekaClient // 本应用 自动注册进eureka服务中
@EnableDiscoveryClient // 服务发现
@EnableCircuitBreaker//对hystrixR熔断机制的支持
public class DeptProvider_hystrix8001_App {
    public static void main(String[] args) {

        SpringApplication.run(DeptProvider_hystrix8001_App.class, args);
    }

    /**
     * 解决springcloud2.0 没有/hystrix.sream没有该路径的404错误
     *
     * @return
     */
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet() {
        ServletRegistrationBean registration = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        registration.addUrlMappings("/hystrix.stream");
        return registration;
    }
}
